package com.dkd.day20250705;



import java.util.Scanner;

public class Main5 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        int[] result = new int[n];
//        for (int i = 0; i < n; i++) {
//            //复制数组
//           int [] arrCopy  = new int [arr.length];
//           for (int j = 0; j < arr.length; j++) {
//               arrCopy[j] = arr[j];
//           }
//           //计算sum
//            int sum = 0;
//            sum += arr[i];
//            System.out.print("初次sum");
//            System.out.print(sum);
//            System.out.print(" ");
//            arrCopy[i] = -1;
//            //建立比较节点
//            //左右边界
//            int leftbound = 0;
//            int rightbound = arr.length - 1;
//            //左右缺口
//            int left = i- 1<0?0:i-1;
//            int right = i +1<0?0:i+1;
//            //循环n-1次，能加上所有数
//            for (int j = 0; j < arr.length -1; j++) {
//                int max = 0;
//                //寻找最大的数，并更新
//                max = Math.max(
//                        Math.max(
//                                Math.max(
//                                        exist(arrCopy,rightbound),exist(arrCopy,leftbound)),
//                                exist(arrCopy,right)),
//                        exist(arrCopy,left));
//                //右边界被选择，-1
//                if(rightbound<arrCopy.length && max == arrCopy[rightbound]){
//                    arrCopy[rightbound] = -1;
//                    rightbound = rightbound -1<0 ? 0 : rightbound-1; ;
//
//                }
//                //左边界被选择 ，加1
//                else if(leftbound >0 && max == arrCopy[leftbound]){
//                    arrCopy[leftbound] = -1;
//                    leftbound = leftbound +1 > arrCopy.length?arrCopy.length:leftbound + 1;
//                }
//                //右缺口被选择，加1
//                else if( right<arrCopy.length && max == arrCopy[right]){
//                    arrCopy[right] = -1;
//                    right = right + 1> arrCopy.length? arrCopy.length:right + 1;
//                }
//                //左缺口被选择，减1
//                else{
//                    arrCopy[left] = -1;
//                    left = left -1 <0?0:left-1;
//                }
//                if(j%2 == 1){
//                    sum += max;
//                    System.out.print(sum);
//                    System.out.print(" ");
//                }
//            }
//            result[i] = sum;
//            System.out.println();
//        }


        for(int i = 0; i < n; i++){
            int sum = arr[i];
            //左右边界
            int right = i+1>arr.length-1? 0:i+1;
            int left = i-1<0?arr.length-1:i-1;
            System.out.printf("第%d次循环",i);
           // System.out.println(i);
            for(int j = 0; j < arr.length-1; j++){
                System.out.println(j);
                int num = 0;
                if(arr[right]>arr[left]){
                    num = arr[right];
                    right = right+1>arr.length-1?0           :right+1;
                    System.out.print("此时right:");
                    System.out.print(right);
                }else{
                    num = arr[left];
                    System.out.println(left);
                    left = left-1  <0           ?arr.length-1:left-1;
                    System.out.print("此时left:");
                    System.out.println(left);
                }
                if(j%2==1){
                    sum+=num;
                }
            }
            result[i] = sum;
        }

        for (int i = 0; i < n; i++) {
            System.out.println(result[i]);
        }
    }

    public static int exist(int[] arr, int target) {
        if(target < 0 || target > arr.length - 1){
            return -2;
        }else return arr[target];
    }
}
